<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java对象模型完全指南 - 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
            position: relative;
        }
        
        .code-block::before {
            content: 'Java';
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 12px;
            color: #666;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            margin: 20px 0;
        }
        
        .concept-card {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .concept-card:hover {
            border-color: #667eea;
            transform: translateY(-4px);
            box-shadow: 0 15px 40px rgba(102, 126, 234, 0.2);
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
        
        .table-container {
            overflow-x: auto;
            margin: 20px 0;
        }
        
        table {
            min-width: 100%;
            border-collapse: collapse;
        }
        
        th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 12px 16px;
            text-align: left;
            font-weight: 600;
        }
        
        td {
            padding: 12px 16px;
            border-bottom: 1px solid #e5e7eb;
        }
        
        tr:hover {
            background: #f9fafb;
        }
        
        .icon-feature {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 48px;
            height: 48px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 12px;
            color: white;
            font-size: 20px;
            margin-bottom: 16px;
        }
        
        .quote-box {
            border-left: 4px solid #667eea;
            padding-left: 20px;
            margin: 20px 0;
            font-style: italic;
            color: #4b5563;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-20">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    Java对象模型完全指南
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    PO、DTO、VO、BO...彻底搞懂Java世界的"O"军团
                </p>
                <div class="flex justify-center space-x-6 text-sm">
                    <span><i class="fas fa-user-circle mr-2"></i>技术小馆</span>
                    <span><i class="fas fa-calendar mr-2"></i>2025年1月</span>
                    <span><i class="fas fa-clock mr-2"></i>15分钟阅读</span>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12 max-w-6xl">
        <!-- Introduction -->
        <div class="content-card rounded-2xl p-8 mb-8">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">作</span>为一名 Java 开发者，你是否曾在代码评审或技术面试中被问到："PO、DTO、VO 有什么区别？"然后瞬间大脑一片空白？别担心，你不是一个人。Java 世界中的这些"O"们确实让人眼花缭乱。它们就像是一个个穿着相似制服的士兵，乍一看几乎一模一样，但实际上各自担负着不同的职责。今天，我们就来一次彻底的"O"军大检阅，让你不仅能应对面试官的刁难，更能在实际项目中游刃有余地运用这些概念，写出更加优雅、可维护的代码。
            </p>
        </div>

        <!-- Object Model Overview Diagram -->
        <div class="content-card rounded-2xl p-8 mb-8">
            <h2 class="text-2xl font-bold mb-6 section-title">对象模型全景图</h2>
            <div class="mermaid">
                graph TB
                    DB[(数据库)]
                    PO[PO<br/>持久化对象]
                    BO[BO<br/>业务对象]
                    DTO[DTO<br/>数据传输对象]
                    VO[VO<br/>视图对象]
                    UI[前端界面]
                    
                    DB <--> PO
                    PO --> BO
                    BO --> DTO
                    DTO --> VO
                    VO --> UI
                    
                    style DB fill:#f9f,stroke:#333,stroke-width:2px
                    style PO fill:#bbf,stroke:#333,stroke-width:2px
                    style BO fill:#bfb,stroke:#333,stroke-width:2px
                    style DTO fill:#fbf,stroke:#333,stroke-width:2px
                    style VO fill:#ffb,stroke:#333,stroke-width:2px
                    style UI fill:#fbb,stroke:#333,stroke-width:2px
            </div>
        </div>

        <!-- Section 1: Origin and Evolution -->
        <div class="content-card rounded-2xl p-8 mb-8">
            <h2 class="text-3xl font-bold mb-8 section-title">
                <i class="fas fa-history text-purple-600 mr-3"></i>Java对象模型的起源与演变
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="concept-card">
                    <div class="icon-feature">
                        <i class="fas fa-question-circle"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">为什么需要这么多对象？</h3>
                    <p class="text-gray-600">
                        还记得你第一次接触企业级 Java 项目时的感受吗？面对满屏的 UserPO、UserDTO、UserVO，你可能会想："为什么不能只用一个 User 类就搞定呢？"
                    </p>
                    <div class="quote-box mt-4">
                        实际上，这些不同的对象模型是为了解决软件工程中的一个核心问题：<strong>关注点分离</strong>。
                    </div>
                </div>
                
                <div class="concept-card">
                    <div class="icon-feature">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">从 MVC 到多层架构</h3>
                    <p class="text-gray-600 mb-4">
                        Java 对象模型的演变与架构模式的发展密不可分。随着应用复杂度提高，简单的分层已不足以应对挑战。
                    </p>
                    <div class="bg-gray-100 p-4 rounded-lg">
                        <code class="text-sm">表现层 → 业务层 → 持久层 → 数据库</code>
                    </div>
                </div>
            </div>

            <div class="highlight-box">
                <h4 class="text-xl font-bold mb-3">
                    <i class="fas fa-shopping-cart mr-2"></i>企业级应用中的数据流转
                </h4>
                <p class="mb-4">想象一下，当用户在电商平台下单时，数据的流转过程：</p>
                <ol class="space-y-2">
                    <li><i class="fas fa-database mr-2"></i>数据库中存储着商品的基本信息</li>
                    <li><i class="fas fa-server mr-2"></i>应用需要从数据库读取这些信息</li>
                    <li><i class="fas fa-cogs mr-2"></i>业务层需要对数据进行处理（如计算折扣、库存检查）</li>
                    <li><i class="fas fa-desktop mr-2"></i>最终，前端需要展示经过处理的数据</li>
                </ol>
            </div>
        </div>

        <!-- Section 2: Common Object Models -->
        <div class="content-card rounded-2xl p-8 mb-8">
            <h2 class="text-3xl font-bold mb-8 section-title">
                <i class="fas fa-cubes text-purple-600 mr-3"></i>常见的Java对象模型
            </h2>

            <!-- PO -->
            <div class="mb-8">
                <h3 class="text-2xl font-bold mb-4 flex items-center">
                    <span class="bg-blue-500 text-white px-3 py-1 rounded-lg mr-3">PO</span>
                    Persistent Object - 持久化对象
                </h3>
                <p class="text-gray-600 mb-4">
                    PO 是与数据库表结构一一对应的对象，是 ORM（对象关系映射）的基础。它就像是数据库的"大使"，忠实地反映了数据库的结构。
                </p>
                <pre class="code-block p-4"><code>@Entity
@Table(name = "users")
public class UserPO {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "username", length = 50, nullable = false)
    private String username;
    
    @Column(name = "password", length = 100, nullable = false)
    private String password;
    
    @Column(name = "email", length = 100)
    private String email;
    
    @Column(name = "created_at")
    private Date createdAt;
    
    // getter 和 setter 方法
}</code></pre>
            </div>

            <!-- DTO -->
            <div class="mb-8">
                <h3 class="text-2xl font-bold mb-4 flex items-center">
                    <span class="bg-green-500 text-white px-3 py-1 rounded-lg mr-3">DTO</span>
                    Data Transfer Object - 数据传输对象
                </h3>
                <p class="text-gray-600 mb-4">
                    DTO 专注于在不同层之间传输数据，通常包含多个来源的数据。它就像是层与层之间的"信使"，携带着必要的信息。
                </p>
                <pre class="code-block p-4"><code>public class UserRegistrationDTO {
    private String username;
    private String password;
    private String email;
    private String captchaCode;
    private boolean agreeToTerms;